#include "matchandroidpicture.h"
#include "ui_matchandroidpicture.h"
#include <QHash>
#include <QFile>
#include <QDebug>
#include <QRegExp>
MatchAndroidPicture::MatchAndroidPicture(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MatchAndroidPicture)
{
    ui->setupUi(this);
    QHash <QString,QString> m_hash;
    m_hash=matchAndroidIcon();

    QHash<QString, QString>::iterator mi;

    mi = m_hash.find("企业微信");
//    if(mi != m_hash.end())
//    {
//        qDebug() << mi.key() <<"   --     " << mi.value();
//        ++mi;
//        if(mi != m_hash.end())
//        {
//            qWarning() << mi.key() <<"  ++      " << mi.value();
//        }
//    }

    QHash<QString, QString>::iterator i;
    for( i=m_hash.begin(); i!=m_hash.end(); ++i){
        if(i.key()=="企业微信")
        qWarning() << i.key() <<"    ×××    " << i.value();
    }


}

MatchAndroidPicture::~MatchAndroidPicture()
{
    delete ui;

}

QHash<QString,QString> MatchAndroidPicture::matchAndroidIcon()
{
    QHash<QString,QString> hash;
    printf("*************\n");
    QFile file("/home/kylin/kylin-desktop/ukui-panel-example/分解用例/窗口切换/安卓兼容应用图标匹配/name-picture.txt");
    if(!file.open(QIODevice::ReadOnly))  qDebug()<<"Read FIle failed";
    while (!file.atEnd()){
        QByteArray line= file.readLine();
//        qWarning()<<"line :"<<line;
        QString str=file.readLine();
        str.section('picture',1,1).trimmed().toStdString();
        str.simplified();
        QString str_name = str.section(QRegExp("[;]"),0,0);
        str_name = str_name.simplified();
        str_name = str_name.remove("name=");

        QString str_icon = str.section(QRegExp("[;]"),1,1);
        str_icon = str_icon.simplified();
        str_icon = str_icon.remove("icon=");

        hash.insert(str_name,str_icon);
    }

    return hash;
}




